<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@include file="../common/default.jsp"%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>优问-随时随地分享点评</title>
<link rel="stylesheet" type="text/css" href="/css/validator.css" />
<script type="text/javascript" src="/js/ask/ask.js"></script>
<script type="text/javascript" src="/js/formValidator-4.0.1.js"></script>
<script type="text/javascript" src="/js/formValidatorRegex.js"></script>
<style type="text/css">
* {
	margin: 0;
	padding: 0;
}

body {
	font-size: 12px;
	font-family: "Microsoft Yahei", "微软雅黑", Tahoma, Arial, Helvetica,
		STHeiti;
	color: #5F6468;
}

a img,*:link img,*:visited img{
	border:none;
}

a {
	text-decoration: none;
	color: #5F6468;
}

.clear {
	clear: both;
}

.text {
	border: 1px solid #CFCFCF;
	color: #999999;
	height: 30px;
	line-height: 30px;
	margin-left: 8px;
	padding-left: 8px;
	width: 226px;
}

.logo {
	width: 960px;
	margin: 0 auto 20px;
}

.logo img {
	margin-right: 5px;
	vertical-align: middle;
}

#registerDiv {
	width: 960px;
	min-height: 500px;
	margin: 0 auto;
	box-shadow: 0 0 3px #ccc;
	padding: 20px;
	background: #fff;
	border-radius: 5px;
}

.regLeft {
	width: 900px;
	height: 400px;
	margin:0 auto;
	padding:100px 0 0 0px;
}

#registerDiv .inner {
	padding: 0 26px;
}

h3 {
	color: #768263;
	font-size: 26px;
	font-weight: normal;
	margin-bottom: 26px;
}

.rst_login {
	margin-left: 32px;
	margin-top: 38px;
}

.rst_login a {
	background: #90C43C;
	border-radius: 3px;
	line-height: 29px;
	text-align: center;
	color: #fff;
	font-size: 14px;
	display: block;
	height: 29px;
	margin-top: 10px;
	width: 111px;
}

.other_login {
	margin-left: 32px;
	margin-top: 65px;
}

.other_login a {
	margin-top: 10px;
	display: block;
}

#register_form span {
	color: #333333;
	float: left;
	font-size: 14px;
	text-align: center;
	vertical-align: middle;
	position:relative;
	top:3px;
}

#register_form .text {
	border: 1px solid #CFCFCF;
	float: left;
	height: 30px;
	line-height: 30px;
	margin-left: 5px;
	width: 254px;
}

.ipt_mail,.ipt_ulike,.ipt_sex,.ipt_password,.ipt_respassword,.ipt_check
	{
	line-height: 30px;
	overflow: hidden;
	margin-top: 20px;
	margin-left: 48px;
}

#register_form .check {
	border: 1px solid #CFCFCF;
	float: left;
	height: 30px;
	line-height: 30px;
	margin-left: 5px;
	width: 114px;
}

.ipt_check #img_checkcode {
	float: left;
	height: 26px;
	margin-left: 4px;
	margin-top: 2px;
	text-align: center;
	vertical-align: middle;
	width: 78px;
}

.ipt_check {
	margin-left: 34px;
}

.ipt_respassword {
	margin-left: 20px;
}

.ipt_mail {
	margin-left: 20px;
	margin-top: 32px;
}

.ipt_sex {
	height: 30px;
}

.ipt_box {
	margin-left: 91px;
	margin-top: 20px;
	overflow: hidden;
}

.fl {
	display: inline;
	float: left;
}

#register_form .ipt_box span {
	color: #999999;
	display: inline;
	font-size: 12px;
	line-height: 12px;
	margin-top: 0;
}

.ipt_sub {
	margin-left: 92px;
	margin-top: 20px;
	overflow: hidden;
}

.ipt_sub .sub {
	background: #FF5A00;
	border-radius: 3px;
	line-height: 29px;
	text-align: center;
	color: #fff;
	font-size: 14px;
	border: none;
	cursor: pointer;
	height: 29px;
	width: 131px;
}

.ipt_sex .rdo .ck {
	margin-top: -3px;
	text-align: center;
	vertical-align: middle;
	margin-left: 10px;
}

.ipt_check a {
	color: #87B32E;
	float: left;
	margin-left: 6px;
}


#register_error {
	float: left;
	width: 280px;
}

.err_email,.err_ulike,.err_password,.err_rstpassword,.err_check {
	color: #999999;
	font-size: 12px;
	line-height: 114%;
	margin-top: 30px;
	height: 26px;
	padding-top: 10px;
	visibility: visible;
}

.err_ulike,.err_check {
	height: 36px;
	margin-top: 15px;
}

.err_rstpassword {
	margin-top: 20px;
}

.err_password {
	margin-top: 60px;
	padding-top: 10px;
}

#register_error img {
	float: left;
	text-align: center;
	margin-left: 5px;
	vertical-align: middle;
}
</style>
</head>
<body>
<%@include file="../common/loginHead.jsp"%>
<div class="regLeft">
			<div class="inner">
				<h3>欢迎入住优问网</h3><br />
				 <span><b style="color:red;margin-right:5px;">*</b>您是站外用户，补充必要的个人信息才能真正入住优问网哦</span>				<div id="register_form">
					<form id="regist_form" action="/user/registUser.action" method="post">
						<div class="ipt_mail">
							<span>电子邮箱：</span> <input id="regist_email" name="user.loginName" class="text r3"
								type="text" maxlength="64"/>
							<span id="regist_emailTip"></span>
						</div>
						<div class="ipt_ulike">
							<span>昵称：</span> <input id="regist_nickname" value="<s:property value='user.nickname' />" name="user.nickname" class="text r3"
								type="text" value="" name="register_ulike" maxlength="20"
								style="*margin-left: -1px;"/>
							<span id="regist_nicknameTip"></span>
						</div>
						<div class="ipt_password">
							<span>密码：</span> <input id="regist_pwd1" name="user.loginPwd" class="text r3"
								type="password" maxlength="20"
								style="*margin-left: -1px;"/>
							<span id="regist_pwd1Tip"></span>
						</div>
						<div class="ipt_respassword">
							<span>确认密码：</span> <input id="regist_pwd2" class="text r3"
								type="password" maxlength="20"/>
							<span id="regist_pwd2Tip"></span>
						</div>
						<input id="user_id" value="<s:property value='user.id' />" name="user.id" type="hidden"/>
						
						<div class="ipt_sub">
							<input class="sub" type="button" onclick="reRegistAcount();" value="完成"/>
						</div>
					</form>
				</div>
			</div>
		</div>
<%@include file="../common/tipDiv.jsp"%>
<%@include file="../common/footer.jsp"%>
<script type="text/javascript">
$(function(){
	//defaultTxt();
	initValidate();
});
function defaultTxt(){
	$('#register_form .text').each(function(){
		defaultvalue($(this));
	});
}
function initValidate() {
	$.formValidator.initConfig({
		formid : "regist_form",
		onerror : function(msg) {
			alertTipDown(msg, "cuo");
			alertTipUp();
		}
	});
	$("#regist_email").formValidator({
		tipid : "regist_emailTip",
		onShow : "如：example@example.com ",
		onFocus : " ",
		onCorrect : "　 "
	}).regexValidator({
		regExp : regexEnum['email'],
		onError : "邮箱地址不正确"
	}).functionValidator({
		fun : function(val, elem) {
			val = $.trim(val);
			if(val == ""){
				return "请填写邮箱地址";
			}
			// 检测邮箱能否用来注册
			var params = {"loginName":val};
			var error = "";
			doAsyncAjax("/userAjax/checkLoginName.action", params, function(ajaxResult) {
				if (!ajaxResult.OK) {
					error = ajaxResult.message
				} 
			});
			if(error != ""){
				return error;
			}
		}
	}).focus(function(){
		$(this).triggerHandler('blur');
	});
	$("#regist_nickname").formValidator({
		tipid : "regist_nicknameTip",
		onShow : "不能以数字开头，中英文、数字、下划线，长度4至20，一个汉子算两个字符",
		onFocus : " ",
		onCorrect : "　 "
	}).inputValidator({
		min : 4,
		max : 20,
		onError : "昵称最少4、最多20个字符"
	}).regexValidator({
		regExp : "^[a-zA-Z_0-9\u4E00-\u9FA5\s\\(\\)\\.]+$",
		onError : "昵称格式不合法：中英文、数字、下划线"
	}).functionValidator({
		fun : function(val, elem) {
			val = $.trim(val);
			if (val == "") {
				return "请填入昵称";
			}
			// 检测昵称用来注册
			var params = {"nickName":val,"userId":$.trim($("#loginUserId").val())};
			var error = "";
			doAsyncAjax("/userAjax/checkNickname.action", params, function(ajaxResult) {
				if (!ajaxResult.OK) {
					error = ajaxResult.message
				} 
			});
			if(error != ""){
				return error;
			}
		}
	});
	$("#regist_pwd1").formValidator({
		tipid : "regist_pwd1Tip",
		onShow : "",
		onFocus : " ",
		onCorrect : "　 "
	}).inputValidator({
		min:6,
		max:20,
		empty:{leftEmpty:false,rightEmpty:false,emptyError:"密码两边不能有空格"},
		onError:"密码长度：6-20位"
	}).regexValidator({
		regExp : "^[\@A-Za-z0-9\!\#\$\%\^\&\*\.\~]{6,20}$",
		onError : "密码不合法：6-20个字母、数字或符号"
	});
	$("#regist_pwd2").formValidator({
		tipid : "regist_pwd2Tip",
		onShow : "",
		onFocus : " ",
		onCorrect : "　 "
	}).inputValidator({
		min:6,
		max:20,
		empty:{leftEmpty:false,rightEmpty:false,emptyError:"密码两边不能有空格"},
		onError:"密码长度：6-20位"
	}).compareValidator({
		desID:"regist_pwd1",
		operateor:"=",
		onError:"2次密码不一致,请确认"
	});
}

function reRegistAcount(){
	if(!$.formValidator.pageIsValid('1')){
    	return false;
    }
	//获取参数
	var rEmail = $.trim($("#regist_email").val());
	var rNick = $.trim($("#regist_nickname").val());
	var rPwd = $.trim($("#regist_pwd1").val());
	var params = {
		"user.id" : $.trim($("#loginUserId").val()),
		"user.loginName" : rEmail,
		"user.nickname" : rNick,
		"user.loginPwd" : rPwd,
		"user.email" : rEmail
	};
	doAsyncAjax("/userAjax/reBindAccount.action",params,function(ajaxResult){
		if(ajaxResult.OK){
			alertTipDown(ajaxResult.message, "dui");
		}else{
			alertTipDown(ajaxResult.message, "cuo");
		}
		alertTipUp();
		location = "/user/userSetting.action";
	});
}
</script>
</body>
</html>
